/*
输入：numbers = [2,7,11,15], target = 9
输出：[1,2]
解释：2 与 7 之和等于目标数 9 。因此 index1 = 1, index2 = 2 。

输入：numbers = [2,3,4], target = 6
输出：[1,3]
*/
#include<bits/stdc++.h>
using namespace std;
class Solution {
public:
    vector<int> twoSum(vector<int>& numbers, int target) {
        int low=0,high=numbers.size()-1;
		while(low<high){
			int sum=numbers[low]+numbers[high];
			if(sum==target){
				return {low+1,high+1};
			}else if(sum<target){
				++low;
			}else{
				--high;
			}
		} 
		return {-1,-1};
    }
};